package com.meixiang.activity.homes.shopping;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.lzy.okhttputils.OkHttpUtils;
import com.meixiang.R;
import com.meixiang.adapter.shopping.SelectStagePayAdapter;
import com.meixiang.dialog.TradersPasswordtKeyDialog;
import com.meixiang.main.BaseActivity;
import com.meixiang.recyclerview.OnItemClick;
import com.meixiang.tool.Tool;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 选择美分期支付
 *
 * @author LZRUI
 */
public class SelectStagePayPlatformActivity extends BaseActivity implements OnItemClick {

    @Bind(R.id.tv_total_amount)
    TextView tvTotalAmount;
    @Bind(R.id.tv_handling_charge)
    TextView tvHandlingCharge;
    @Bind(R.id.ry_stage)
    RecyclerView ryStage;

    private int selectPosition = 0; // 选中的position，默认选中第一个

    private SelectStagePayAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_select_stage_pay_platform);
        ButterKnife.bind(this);
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);
        OkHttpUtils.getInstance().cancelTag(SelectStagePayPlatformActivity.this);
    }

    @Override
    protected void initTitle() {
        setTitle("选择美分期");
    }

    @Override
    protected void initView() {
        ryStage.setAdapter(adapter = new SelectStagePayAdapter());
        ryStage.setLayoutManager(new LinearLayoutManager(this));
        adapter.setOnItemClick(this);
    }

    @Override
    protected void setData() {

    }

    @Override
    @OnClick(R.id.tv_pay)
    public void onClick(View v) {
        if (Tool.isFastDoubleClick()) return;
        Toast.makeText(this, "当前选中：" + selectPosition, Toast.LENGTH_LONG).show();
        TradersPasswordtKeyDialog dialog=new TradersPasswordtKeyDialog(this,"美分期","12356.25", new TradersPasswordtKeyDialog.OnCustomDialogListener() {
            @Override
            public void getPayPassWord(TradersPasswordtKeyDialog paymentKeyDialog, String password) {
            }
        });
    }

    @Override
    public void onItemClick(View view, int position) {
        selectPosition = position;
    }
}
